package com.moetube.web.controller;

import com.alibaba.fastjson.JSON;
import com.moetube.user.feign.UserFeign;
import com.moetube.user.pojo.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * @description:用户渲染服务
 * @author: xc
 * @time: 2020/01/02 17:37
 */
@Controller
@RequestMapping("/wuser")
public class UserController {

    @Autowired
    private UserFeign userFeign;

    @GetMapping("/{username}")
    public String user(@PathVariable("username") String username, Model model) {

        User user1 = userFeign.findByUsername(username).getData();
        String user = JSON.toJSONString(user1);
        model.addAttribute("user", user);

        return "user";
    }

}
